@analysis_bp.route('/kmeans', methods=['POST'])
def kmeans_analysis():
    try:
        data = request.get_json()
        dataset_id = data.get('dataset_id')
        n_clusters = data.get('n_clusters', 3)
        
        if not dataset_id:
            return jsonify({'error': '缺少数据集ID'}), 400
            
        # 获取所有可视化结果
        visualizations = kmeans_visualization(dataset_id, n_clusters)
        
        return jsonify({
            'status': 'success',
            'data': {
                'visualizations': visualizations
            }
        })
        
    except Exception as e:
        return jsonify({'error': str(e)}), 500 